package a3;

import java.util.TreeSet;

//TODO possibleActions with standing still
public class Prey extends Agent {
	
	private float tripChance;

	public Prey(Location spawn, Environment env, float alpha, float gamma, float epsilon, String algorithm, float initQ, int ID) {
		super(spawn, env, alpha, gamma, epsilon, algorithm, initQ, ID);
		tripChance = 1f;
	}
	
	@Override
	public void takeAction() {
		if(Tools.RandomGenerator.nextFloat() > tripChance) {
			Action a = lastSApair.getValue();
			Location.x = Tools.mod((Location.x + a.x), Environment.BoardSize);
			Location.y = Tools.mod((Location.y + a.y), Environment.BoardSize);
		}
	}
	
	@Override
	int getReward(){
		State s = getState();
		TreeSet<Location> locOthers = s.locOthers;
		Location locPrey = s.locPrey;
		
		if (locOthers.size() < Environment.getPredators().size())
			return 10;
		else if (locOthers.contains(locPrey))
			return -10;
		return 0;
	}
}
